Skip to content

FIX-2280: the Teammates lab reads a worker's project from its conversation - #4086

Merged
jhoffner merged 31 commits into
mainfrom
claude/project-thread-o2af7c
Oct 28, 2026
Merged

jhoffner merged 31 commits into
mainfrom
claude/project-thread-o2af7c

Conversation

@jhoffner

@jhoffner jhoffner commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

The problem

The Teammates lab named a worker's project from the answer of its own last setWorkProject request. A pick made in another tab or client did not show. In a long conversation the pick could drop out of the requests the lab read.

What this does

This builds the approved FIX-2280 spec.

  • Teammates lab: watchWorkProject polls the conversation's session read and names its workProjectId. A pick here shows at once, and a later read that differs from what is shown always reaches the screen. The request-answer read and the in-tab picked memo are gone. A private project names none, because the screen lists only shared projects. The README's wiring row is updated and the FIX-2280 "Not wired yet" bullet removed.
  • Workforce test: on the built-in agent flow (the flow lead, researcher and writer run on), a project set from a second client shows on the first client's read and on listWorkerSessions. A change shows too. A create that seeds the field gets 400. Another user can't read the session. (FIX-2153: wire the Claude Code-style lab's session mode to the real packages #4073 has since merged with its own coordinator-flow read test; both are kept.)
  • Docs: packages/workforce/README.md and apps/docs/docs/workforce/projects.md say how to read the project back, and how it differs from projectId.
  • Ported fix from main: packages/orchestration/test/task-board/settles-when-its-work-is-over.test.ts still named the old human_input suspension reason (refactor(FIX-2151): the suspension reasons say user #4093 renamed it to user_input while FIX-2157: wire the Claude Code-style lab's threads mode to the real packages #4094 added the test), so main fails the vocabulary sweep. One word, same fix wherever it lands first.

#4079 (the Teammates lab wiring) has merged; this PR now targets main.

Goal check

Signal Result
elsewhere, listing, changed, no-write, other-user (workforce test on the agent flow) PASS
Control: expose removed FAIL: expected { workerId: 'writer' } to match object { workProjectId: 'shared/apollo' }
lab (adapter's read maps the stored field; shown-on-change sequence) PASS
Control: the lab's read returns nothing FAIL on the named-project test

One change from the spec: the lab test checks the adapter's pure read, workProjectOf(state), not a fake client. A fake client for ensureWorkerSession would mostly test the fake. The package test covers the read path end to end.

Parts worth reviewing closely

  1. packages/workforce/test/projects-harness.ts. Extra flows are now created with { id: <key> }, because the agent flow is a collection flow. All 10 test files that use the harness pass (145 tests).

Verification

  • packages/workforce: the 10 harness test files, 145/145.
  • labs/teammates: typecheck clean, 27/27 tests, inventory.mjs --wired PASS (README table rewritten).
  • packages/orchestration: the ported test file, 35/35; vocabulary sweep PASS.
  • check-retired-terms PASS. Lint clean.
  • No changeset: FIX-2153: wire the Claude Code-style lab's session mode to the real packages #4073 carried the package's changeset. The lab is private.

Spec specs/issues/FIX-2280 · FIX-2280 · epic FIX-2152

How to review this: implementation PR. Is it correct, and does it match the approved direction?

Judge correctness and second paths: a conversation with no project, a private project, a project set by another client, and auth from caller-controllable input. Please don't re-litigate what the spec decided: read through the session read, not a workforce client call.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NczDiFjomt1WzivnJPVSoF

claude added 11 commits October 28, 2026 18:51
The lab now runs on a real model and a durable SQLite store through
`fsdev dev --app`: lead, researcher and writer on the built-in agent flow
with memory composed in, coder on the lab's one coding flow (one
harnessManager per harness over projectWorkspace(), routed by the worker's
`harness:`), and the user's projects created at start. The adapter calls
the workforce client, session items and streams, the message log, and
setWorkProject; the fixtures are gone (kept only as a test double).

Adds the goal check goals/teammates-lab/a-worker-talks-to-another-while-you-talk
(steps 1-3 and 5 in a browser; step 4 waits on FIX-1613), and lets
launchChromium find a pre-installed chrome-linux64 build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
Opens the page on the first worker you can talk to, shows "idle" before a
worker's first turn, opens the roster before reading projects (a fresh
store had none to list yet), and labels a pending run without a project.
lead's WORKER.md now says to file code changes with a title and goal and
nothing in `input` (FIX-2282). The goal grades step 5 on its own task cards
and records PASS twice plus all four controls failing their steps. The
README lists what isn't wired: G1 (FIX-1613), FIX-2280, FIX-2281, FIX-2282.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
fsdev loads fsdev.config.mts by path, so nothing imports it; like
knowledge-hub's, it is an entry point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
- watchWorkProject reads the last setWorkProject answer once, over every
  page of finished requests, then follows the picks made on this page, in
  place of re-reading 200 requests with their output every 1.5 s.
- watchRun's run session comes from the task rows watchTasks reads, and its
  wait stops once the run's feed is attached.
- The goal waits for coder's result after your pick, not the refused task's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
… paged

Each later page starts on the last item held, as useSession reads it; a page
that doesn't means a keyed item moved and an older one may have been
skipped, so the read starts over. The new test loses item 10 of 502 on the
old read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
CODEX_PASS moves from the kitchen sink into @flow-state-dev/codex, next to
claude-code's CLAUDE_CODE_PASS, and the Teammates lab's codex harness builds
client.env from it instead of inheriting the server's whole process.env.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
watchRun takes the run session the task row names, so the runOf map and its
wait poll go. The README inventory is regenerated, which ed88b9f's host.mts
change had left stale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
…ation

The lab named a worker's project from its own last setWorkProject answer, so a
pick made in another tab or client never showed and a long conversation could
lose it. It now reads workProjectId off the session read, which every worker
session exposes (ported from FIX-2278, #4073; it no-ops once that merges).

- workforce: a test on the built-in agent flow that a project set from a second
  client shows on the first client's read and listing, can't be seeded, and
  isn't readable by another user. Red without the expose.
- labs/teammates: watchWorkProject polls the session read; the request-answer
  read and the in-tab memo are gone.
- docs: README and projects.md say how to read the project back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFjomt1WzivnJPVSoF
@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 28, 2026 11:11pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 28, 2026 11:11pm UTC
flow-state-dev-ui Ignored Ignored Preview Oct 28, 2026 11:11pm UTC

Request Review

@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

FIX-2280

@jhoffner jhoffner self-assigned this Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T23:00:00.941962Z — New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify / approach review (FIX-2280)

Verdict: The workforce change is the right minimal fix; the Teammates delta is a real simplification. Approve — nothing here blocks merge on architecture grounds.

Did this go too far?

No on the package side. workProjectId was already server-owned session state; it just was not client-projected, so any UI that needed authoritative project (including picks from another tab/client) could not read it without inventing a side channel. Wiring client: { expose: [WORK_PROJECT_STATE_KEY] } through installation.session() matches the existing FSD projection model (same idea as per-flow client.expose elsewhere) and applies once to every worker flow. A lab-only workaround would stay wrong or fragile:

Alternative Why I'd skip it
Keep paginating completed setWorkProject requests with includeResultOutput Not the source of truth; expensive on long histories; still wrong once you page past the last action
Only update local cache when this tab calls setWorkProject That was the original bug (FIX-2280)
New RPC just for "current project" Same data as session read, more surface area

The old adapter path (~40 lines of picked / pickWatchers / request paging) was the complexity smell; this PR removes it.

Lab layer

workProjectOf + parseProjectRef from @flow-state-dev/workforce/browser is appropriate: Teammates UI policy (shared projects only → bare id) should not reuse server-side filingProjectOf (coordinator/filed precedence). Exporting the helper for unit tests is fine.

Cross-imports look clean: lab → /browser only, not workforce internals.

Tradeoffs worth knowing (optional follow-ups, not blockers)

  1. Polling fan-out: watchWorkProject now uses shared poll() (1.5s) + sessions.get. Each useWatch subscriber gets its own timer. In Runs, every FiledBy row calls watchWorkProject(filer.id) — so steady load scales with the number of conversational workers, even though poll dedupes UI updates, not HTTP. The old path was worse at cold open (paged history scan) but silent when idle. Consider a per-worker singleton poller (reuse the old pickWatchers shape, but read session state) if DevTools shows chatter in Runs view.

  2. Local pick latency: Removing picked.set + synchronous watcher fan-out on setWorkProject means the UI may wait up to one poll tick for its own pick unless the select is already optimistic in React. Small UX regression possible; could push the new value locally after a successful setWorkProject while keeping session read for cross-tab truth.

  3. Release notes: If @flow-state-dev/workforce consumers should notice session reads now include workProjectId, a .changeset fragment may be warranted (BP-022) — confirm against your release habit for projection additions.

  4. Harness tweak: flowOf(flow)({ id: name }) in projects-harness.ts is justified for the new agent-flow test; it slightly widens the diff but is not product complexity.

Docs / tests

Workforce integration test for cross-client read on the agent flow + docs snippet in projects.md match the new contract. Teammates unit tests cover workProjectOf filtering; cross-tab behavior is appropriately owned by the package test.


Net: correct direction, smaller lab, appropriate framework exposure. Inline notes call out the two lab-side polish items I'd consider if you touch this file again soon.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

Comment thread labs/teammates/src/adapter.ts Resolved
Comment thread labs/teammates/src/adapter.ts Resolved

Copy link
Copy Markdown
Collaborator Author

Second look + architecture pass

Verdict: the approach is right and lean (+91/−49, net deletion of the picked memo, pickWatchers and the paging loop). I found no blocker. A few items for the next agent to weigh; none need a redesign.

Worth fixing

  1. Pick now lags by up to POLL_MS (1.5s). setWorkProject used to notify pickWatchers synchronously, so the picker updated at once. Now the screen shows the old project until the next poll tick, and a user can see their pick snap back and then forward. Cheapest fix that keeps the single read path: after workforce.setWorkProject resolves, have setWorkProject re-read once (e.g. return/emit workProjectOf from a client.sessions.get), or let the screen hold the picked value until the poll catches up. Check how watchWorkProject's consumer renders in the gap before choosing; if it already holds local state this is moot.

  2. Coverage gap on the flows the lab actually uses. The new workforce test runs only on the writer (agent flow). expose reaches the session through installation.session() spread, and the coordinator (coordinator-flow.ts:1713) and Error Reporter (error-reporter/flow.ts:710) spread it too, so they should work. But lead/main are the coordinator workers and are in the same harness (standardWorkers). One expect(...state).toMatchObject({ workProjectId }) on lead would pin that, and would fail if a flow ever overrides session.client after the spread (an override replaces expose, it doesn't merge).

  3. PR is mergeable_state: dirty against its base (claude/project-thread-e54cfm). Merge the base in before anything else.

Considered, no change recommended

  • Polling the whole session per watched worker. One full sessions.get every 1.5s per worker. Fine at lab scale. If a stream for session state appears later, this is the call to swap; don't build for it now.
  • workProjectOf in the lab vs. the doc snippet (parseProjectRef(String(state[KEY] ?? ""))). Same parse written twice. A package helper would be the deepening move, but the spec decided "read through the session read, not a workforce client call", so I'd leave it. Revisit only if a third consumer appears.
  • visibility map still only ever stores "shared" (pre-existing; this PR doesn't worsen it). The ?? "shared" in setWorkProject and the shared-only filter in workProjectOf now agree, which is the coherent state.
  • projects-harness.ts { id: name } is passed to every extra flow, including non-collection ones. Harmless if ignored; 144/144 passing says it is.
  • client: { expose } on installation.session() is the right home (BP-015) and keeps one declaration for every worker flow. Return-type widening on the interface is in step with the implementation.

Correctness spot checks passed

No-project (undefined), private (undefined), unparsable value (undefined), other-client write, other-user read (rejects), and seeded create (400) are all covered by the two new tests. poll fires once for an initial undefined and then only on change.


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Snob — already tight. No POC.

Head 6e31e6b22a4ef04b3dfcf480f582568e2a183f9c.

Read labs/teammates/src/adapter.ts, labs/teammates/test/work-project.test.ts, labs/teammates/src/lib/use-watch.ts, labs/teammates/src/components/Conversation.tsx, packages/workforce/src/workers/installation.ts, packages/workforce/test/projects-harness.ts, packages/workforce/test/work-project.test.ts, packages/workforce/src/projects/workstream-ref.ts, and the installation.session() spread in packages/workforce/src/agent-worker-flow.ts. installation.ts is the same bytes as #4073 (53d3e9c03e).

  • watchWorkProject is the existing poll plus sessions.get. The page loop, picked, and pickWatchers are already gone.
  • workProjectOf is the shared-id filter the lab test locks (a private project and a bare id name none). Inlining it copies those three lines into the poll and leaves the test with nothing to call.
  • projectWatchers is the notify after setWorkProject, so the controlled project select does not wait out POLL_MS. A confirming re-read still needs that set to reach useWatch. Holding the pick in the screen means Conversation, Runs, and the card each grow a second value.
  • The harness passes { id: name } because the agent flow is a collection. A branch only for that key is longer.
  • The workforce test’s new lines are the other client’s read, the listing, and the change. The seed-400 and other-user asserts sit on that same test; dropping them does not shorten the read. not-seeded already refuses a seeded create through the same createCheck.
  • The README sentence and the docs example are the read path. No second helper to delete.
Open in Web View Automation 

Sent by Cursor Automation: Code Snob

A worker's answer, a message from another worker and a task's result are drawn
through the UI registry's MessageResponse (Streamdown), copied into the lab's
flow-state components. An unfinished code fence renders as a code block while
the answer streams. Streamdown parses raw HTML by default; the lab drops its
raw rehype plugin so HTML a model writes shows as text. Tests cover the open
fence, Markdown structure and the HTML, and fail on the plain-text entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
…to claude/project-thread-o2af7c

# Conflicts:
#	labs/teammates/README.md
#	labs/teammates/src/adapter.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFjomt1WzivnJPVSoF

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ecb5e55ffd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread labs/teammates/src/adapter.ts Resolved
The pick here was shown without the poll knowing, so a later read equal to the
poll's last one was dropped. Each read now reaches the watch, which compares it
with what the screen last showed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFjomt1WzivnJPVSoF
A Markdown body is a block next to its label, so textContent ran the label
into the text ("reply12 October") and missed the date. entriesOf reads
innerText, and the task-failed check ignores case since innerText applies
the label's uppercase style. Re-run on a real model: PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
The session stream sends an item once it is finished, and a request's stream
read by id carries no text deltas, so answers arrived whole. The lab now
streams its sends and keeps the response's messages as they grow. A failed
snapshot read is read again while the conversation is watched, instead of
leaving the cached feed blank. Tests cover both; the screenshot is retaken
mid-answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
…laywright helper)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFjomt1WzivnJPVSoF
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
…to claude/project-thread-o2af7c

# Conflicts:
#	labs/teammates/README.md
…ever waits on a message

A task filed with resultTo: "conversation" ends as the worker's bare
answer, with no task id on the line, so the lab drew a finished task as
failed. Only a line that names its task and whose row did not finish is
failed now (test/entries.test.ts).

Lead's prompt names the parameter: it never passes wait, so researcher's
reply lands as its own message after lead's answer (goal step 3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
…s for the Talk panel

Two real-model runs failed step 3 for the model's reasons: lead called
researcher (wait) once, and researcher answered in its own conversation
once, which never reaches lead. Researcher's prompt now names inReplyTo
and says only the send reaches the asker. Step 2 counted the Talk panel's
group the moment the panel opened, before it read the log; it waits now.
Verdict logged: PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFEfpmT3smuFRj8ti2
…to claude/project-thread-o2af7c

# Conflicts:
#	labs/teammates/README.md
Base automatically changed from claude/project-thread-e54cfm to main October 28, 2026 22:52
Keeps this PR's session-read watch over the squashed #4079 adapter, and
restores the lab README's wiring row and the dropped FIX-2280 bullet that
earlier README merges had lost; inventory recounted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFjomt1WzivnJPVSoF
…n reason

#4093 renamed it to user_input while #4094 added this test; main fails the
vocabulary sweep on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFjomt1WzivnJPVSoF
The last count ran while the merge still had unmerged entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFjomt1WzivnJPVSoF
@jhoffner
jhoffner merged commit 8892070 into main Oct 28, 2026
18 checks passed
@jhoffner
jhoffner deleted the claude/project-thread-o2af7c branch October 28, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants